package cre.gutwo.swing;

import java.awt.EventQueue;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;

public class OutputDialog extends JDialog {
	private static final long serialVersionUID = -5733840412475695773L;

	private JPanel contentPane;
	private JTextArea textArea;

	/**
	 * Create the frame.
	 */
	public OutputDialog() {
		// setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);

		JScrollPane scrollPane = new JScrollPane();
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING).addComponent(scrollPane,
				GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE));
		gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING).addComponent(scrollPane,
				Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE));

		textArea = new JTextArea();
		scrollPane.setViewportView(textArea);
		scrollPane.setAutoscrolls(true);
		contentPane.setLayout(gl_contentPane);

		for (int i = 0; i < 50; i++) {
			// textArea.append("message\n");
		}
	}

	public void alert() {
		int response = JOptionPane.showOptionDialog(this, "数据转换完成，CSV文件创建成功，是否关闭日志窗口",
				UIManager.getString("OptionPane.titleText"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
				null, null, null);

		if (response == 0)
			dispose();
	}

	public JTextArea getTextArea() {
		return textArea;
	}

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					OutputDialog frame = new OutputDialog();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

}
